package cn.tedu.order.tcc;

import io.seata.rm.tcc.api.BusinessActionContext;
import io.seata.rm.tcc.api.BusinessActionContextParameter;
import io.seata.rm.tcc.api.LocalTCC;
import io.seata.rm.tcc.api.TwoPhaseBusinessAction;

import java.math.BigDecimal;

/**
 * @ClassName OrderTccAction
 * @Description:类描述
 * @Author Tedu
 * @Date 2021/7/2 11:36
 * @Version V1.0
 **/
@LocalTCC
public interface OrderTccAction {
    //Try
    //第二阶段方法名,如果不是默认名,需要添加属性配置
//    @TwoPhaseBusinessAction(
//            name = "OrderTccAction",
//            commitMethod = "commit",
//            rollbackMethod = "rollback"
//    )
//为了避开seata的一个bug,这里不传递封装的Order对象
    @TwoPhaseBusinessAction(
            name = "OrderTccAction"
    )
    boolean prepare(BusinessActionContext ctx,
                    @BusinessActionContextParameter(paramName = "orderId") Long orderId,
                    Long userId,
                    Long productId,
                    Integer count,
                    BigDecimal money
                    );
    //Confirm
    boolean commit(BusinessActionContext ctx);
    //Cancel
    boolean rollback(BusinessActionContext ctx);
}
